package View;

import instruction.User;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.StageStyle;

import java.io.IOException;

public class AddFriendWindow extends window{
    private User friend;

    public User getFriend() {
        return friend;
    }

    public void setFriend(User friend) {
        this.friend = friend;
    }

    public AddFriendWindow() throws IOException {
        root = FXMLLoader.load(getClass().getResource("/Fxml/searchFriend.fxml"));
        Scene scene = new Scene(root, 400, 400);
        scene.setFill(Color.TRANSPARENT);
        setScene(scene);
        initStyle(StageStyle.TRANSPARENT);
        setResizable(false);
        setTitle("We Chat");
        Image image=new Image("/Picture/sourceMaterial/查询好友背景图.jpg",400,400,false,false);
        ((ImageView)$("backgroundImage")).setImage(image);
        move();
        quit();
        setIcon();
        minimiser();
    }

    //退出
    @Override
    public void quit() {
        ((Button) $("exitButton")).setTooltip(new Tooltip("退出"));
        ((Button) $("exitButton")).setOnAction(event -> {
            close();
        });

    }
    //最小化
    @Override
    public void minimiser() {
        ((Button) $("ministerButton")).setTooltip(new Tooltip("最小化"));
        ((Button) $("ministerButton")).setOnAction(event -> {
            setIconified(true);
        });
    }
    public void setFriendData(){
        Circle circle = new Circle();
        circle.setRadius(40);
        circle.setCenterX(40);
        circle.setCenterY(40);
        ((ImageView)$("friendImage")).setImage(new Image(friend.getHead(),80,80,false,false));
        ((ImageView)$("friendImage")).setClip(circle);
        ((Label)$("friendAccount")).setText(friend.getAccount());
        ((Label)$("friendAge")).setText(friend.getAge());
        ((Label)$("friendSign")).setText(friend.getSignature());
        ((Label)$("friendSex")).setText(friend.getSex());
    }


}
